/////////////////////////////////////////////////////////////////////////////
// Name:        toolbarcustdlg.h
// Purpose:     
// Author:      Julian Smart
// Modified by: 
// Created:     11/29/2006 10:15:46 AM
// RCS-ID:      
// Copyright:   (c) Anthemion Software Ltd.
// Licence:     New BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _TOOLBARCUSTDLG_H_
#define _TOOLBARCUSTDLG_H_

/*!
 * Includes
 */

#include "wx/htmllbox.h"
#include "toolbarcust.h"

/*!
 * Forward declarations
 */

////@begin forward declarations
class wxToolCheckListBox;
////@end forward declarations

/*!
 * Control identifiers
 */

////@begin control identifiers
#define ID_WXTOOLBARCUSTOMISATIONDIALOG 10011
#define ID_TOOLBAR_CUST_TOOLBARS 10012
#define ID_ShowToolBarCtrl 10000
#define ID_ShowLabelsCtrl 10001
#define ID_TOOLBAR_CUST_TOOLS 10013
#define SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
#define SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_TITLE _("Customise Toolbars")
#define SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_IDNAME ID_WXTOOLBARCUSTOMISATIONDIALOG
#define SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_SIZE wxSize(400, 300)
#define SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_POSITION wxDefaultPosition
////@end control identifiers

/*!
 * wxToolBarCustomisationDialog class declaration
 */

class wxToolBarCustomisationDialog: public wxDialog
{    
    DECLARE_DYNAMIC_CLASS( wxToolBarCustomisationDialog )
    DECLARE_EVENT_TABLE()

public:
    /// Constructors
    wxToolBarCustomisationDialog( );
    wxToolBarCustomisationDialog( wxToolBarCustomisationManager* manager, wxWindow* parent, wxWindowID id = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_IDNAME, const wxString& caption = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_TITLE, const wxPoint& pos = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_POSITION, const wxSize& size = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_SIZE, long style = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_STYLE );

    /// Creation
    bool Create( wxToolBarCustomisationManager* manager, wxWindow* parent, wxWindowID id = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_IDNAME, const wxString& caption = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_TITLE, const wxPoint& pos = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_POSITION, const wxSize& size = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_SIZE, long style = SYMBOL_WXTOOLBARCUSTOMISATIONDIALOG_STYLE );

    /// Initialises member variables
    void Init();

    /// Creates the controls and sizers
    void CreateControls();

    /// Show toolbar
    void ShowToolbar(int n);

    /// An option was toggled
    void OnCheckListBoxToggled(wxCommandEvent& event);

    /// Get the list of toolbar customisations that were changed
    const wxArrayInt GetChangedndices() const { return m_changed; }

    /// Get the list of toolbar customisations that were changed
    wxArrayString GetChanged() const;

    /// Get the list of toolbar customisations that were changed: visibility only
    const wxArrayInt GetVisibilityChanged() const { return m_visibilityChanged; }

    /// Get the list of toolbar customisations that were changed: tool visibility only
    const wxArrayInt GetToolsChanged() const { return m_toolsChanged; }

    /// Did this toolbar change?
    bool ToolBarChanged(int n) const { return m_changed.Index(n) != wxNOT_FOUND; }

    /// Did this toolbar change?
    bool ToolBarChanged(const wxString& name) const;

    /// Did this toolbar visibility change?
    bool ToolBarVisibilityChanged(int n) const { return m_visibilityChanged.Index(n) != wxNOT_FOUND; }

    /// Did this toolbar visibility change?
    bool ToolBarVisibilityChanged(const wxString& name) const;

    /// Did this toolbar text labels status change?
    bool ToolBarLabelsChanged(int n) const { return m_labelsChanged.Index(n) != wxNOT_FOUND; }

    /// Did this toolbar text labels status change?
    bool ToolBarLabelsChanged(const wxString& name) const;

    /// Did this toolbar's tools change?
    bool ToolsChanged(int n) const { return m_toolsChanged.Index(n) != wxNOT_FOUND; }

    /// Did this toolbar's tools change?
    bool ToolsChanged(const wxString name) const;

    /// Set whether tooltips should be enabled
    void SetShowToolTips(bool show) { m_showToolTips = show; }

    const wxString& GetInitialToolBar() const { return m_initialToolBar; }
    void SetInitialToolBar(const wxString& name) { m_initialToolBar = name; }

////@begin wxToolBarCustomisationDialog event handler declarations

    /// wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_TOOLBAR_CUST_TOOLBARS
    void OnToolbarCustToolbarsSelected( wxCommandEvent& event );

    /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_ShowToolBarCtrl
    void OnShowToolBarCtrlClick( wxCommandEvent& event );

    /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_ShowLabelsCtrl
    void OnShowLabelsCtrlClick( wxCommandEvent& event );

    /// wxEVT_UPDATE_UI event handler for ID_ShowLabelsCtrl
    void OnShowLabelsCtrlUpdate( wxUpdateUIEvent& event );

////@end wxToolBarCustomisationDialog event handler declarations

////@begin wxToolBarCustomisationDialog member function declarations

    /// Retrieves bitmap resources
    wxBitmap GetBitmapResource( const wxString& name );

    /// Retrieves icon resources
    wxIcon GetIconResource( const wxString& name );
////@end wxToolBarCustomisationDialog member function declarations

    /// Should we show tooltips?
    bool ShowToolTips();

////@begin wxToolBarCustomisationDialog member variables
    wxChoice* m_toolbarsCtrl;
    wxCheckBox* m_showToolBarCtrl;
    wxCheckBox* m_showLabelsCtrl;
    wxToolCheckListBox* m_toolListCtrl;
////@end wxToolBarCustomisationDialog member variables

    wxToolBarCustomisationManager*  m_manager;
    wxArrayInt                      m_changed;
    wxArrayInt                      m_visibilityChanged;
    wxArrayInt                      m_labelsChanged;
    wxArrayInt                      m_toolsChanged;
    bool                            m_showToolTips;
    wxString                        m_initialToolBar;
};

/*!
 * wxToolCheckListBox class declaration
 */

class wxToolCheckListBox: public wxHtmlListBox
{
    DECLARE_CLASS(wxToolCheckListBox)
    DECLARE_EVENT_TABLE()

public:
    wxToolCheckListBox(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
        const wxSize& size = wxDefaultSize, long style = 0);
    ~wxToolCheckListBox();

    bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
        const wxSize& size = wxDefaultSize, long style = 0);

    /// Returns the HTML for this item
    virtual wxString OnGetItem(size_t n) const;

    /// Associates the control with a list of icons
    void SetCustomisation(wxToolBarCustomisationInfo* info) { m_info = info; }
    wxToolBarCustomisationInfo* GetCustomisation() const { return m_info; }

    /// Use the customisation
    void UseCustomisation(wxToolBarCustomisationInfo* info);

    // Get icon for index
    // stCardIcon* GetIcon(size_t i) const ;

    /// Updates the list
    void UpdateList();

    /// Sets/gets the selections
    // void SetSelections(const wxArrayString& sel) { m_selections = sel; }
    // const wxArrayString& GetSelections() const { return m_selections; }

    /// Select one item
    // void Select(const wxString& name, bool select = true, bool refresh = true);

    /// Is this item selected?
    // bool IsSelected(const wxString& name) const;

    /// Detect checkbox clicks
    void OnLeftDown(wxMouseEvent& event);

    virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
    virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const;

    /// Clear the memory bitmaps
    void ClearMemoryBitmaps();

    /// Add the memory bitmaps for the current info
    void AddMemoryBitmaps();

private:

    wxToolBarCustomisationInfo*     m_info;
    // wxArrayString                   m_selections;
    wxArrayString                   m_memoryBitmaps;
    wxSize                          m_maxBitmapSize;
};

#endif
    // _TOOLBARCUSTDLG_H_
